#![no_std]
#![no_main]
#![feature(pointer_is_aligned_to)]
#![feature(naked_functions)]
#![feature(ptr_metadata)]
#![feature(ptr_as_ref_unchecked)]
#![allow(named_asm_labels)]
#![allow(static_mut_refs)]

extern crate alloc;

mod io;
mod kernel_hal;
#[macro_use]
mod logging;
mod example;
mod homework;
mod mimalloc;
mod uart;

use crate::example::example5_1;
use crate::homework::{
    homework_5_1, homework_5_2_wrap, homework_5_3_call, homework_5_4, homework_5_5_test1,
    homework_5_5_test2,
};
use core::{arch::global_asm, panic::PanicInfo};

global_asm!(include_str!("boot.s"));

#[panic_handler]
fn panic_handler(info: &PanicInfo) -> ! {
    loop {}
}

#[unsafe(no_mangle)]
fn kernel_main() {
    println!("欢迎来到我的世界");
    unsafe {
        example5_1();
    }

    let max = homework_5_2_wrap(10, 20);
    println!("max: {}", max);
    unsafe {
        homework_5_3_call();
    }
    homework_5_4();
    unsafe {
        let mut ret = homework_5_5_test1(10, 20);
        println!("ret: {}", ret);
        ret = homework_5_5_test2(10, 20);
        println!("ret: {}", ret);
    }
    unsafe {
        let ret = homework_5_1(&[5, 7, 3, 2, 9, 32, 56, 13, 9]);
        println!("最大的数为: {}", ret);
    }
    loop {
        continue;
    }
}
